<template>
  <Layout>
    <Form ref="queryForm" :model="dataToQuery" :label-width="120">
      <Row class="query-form">
        <Col span="8">
          <FormItem label="企业名称：" prop="companyId">
            <div>
              <cascader-dom class="query-form-el" ref='queryOrgCascader' @setOrgname='setQueryOrgName'
                            :orgTree="true"
                            :setCurrentName="{label:dataToQuery.companyName,value:dataToQuery.companyId}"></cascader-dom>
            </div>
          </FormItem>
        </Col>
        <Col span="8" v-if="!switchFlag">
          <!--<Button @click="switchQuery(true)" class="ivu-btn-switch" type="text">展开∨</Button>-->
          <Button @click="reset" class="ivu-btn-reset">重置</Button>
          <Button type="primary" class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
        </Col>
      </Row>
    </Form>
    <Table ref='table' :height="tableHeight" no-data-text="没有查询到相关数据!" @on-selection-change='getSelectRows'
           :loading='pageStatus.loading' @on-expand="onExpand"
           border :columns="columns1" :data="dataTable">
    </Table>
  </Layout>
</template>

<script>
import {Api} from '@/api/index.js'

import cascaderDom from '@/components/cascader-dom.vue';
import pageCommonFunction from '@/components/pageCommonFunction.js'

export default {
  components: {cascaderDom},
  data() {
    return {
      ...this.createCommonDataField(),
      columns1: [
        {title: '序号', width: 80, fixed: 'left', align: 'center', render: this.indexColumnsRender},
        {key: 'title', title: '类别', align: 'center', minWidth: 120,},
        {key: 'count', title: '数量', align: 'center', minWidth: 120,},
      ],
      tableHeight: 10,
      itemModel: false,
      itemAdd: false,
      // api
      queryUrl: Api.queryFireSafetyStat,
      buttonLoading: false,

    }
  },
  computed: {},
  async mounted() {
    this.setTableHeight();
    this.query();
  },
  methods: {
    ...pageCommonFunction,
    query() {
      this.pageStatus.loading = true
      this.$http.get(this.queryUrl, {params: this.dataToQuery}).then((res) => {
        if (res.data.status === 201) {
          this.$Message.error(res.data.msg);
        }
        this.dataTable = res.data.data;
        this.pageStatus.loading = false
      }).catch(e => {
        this.$Message.error("数据获取失败")
        this.pageStatus.loading = false
      })
    },

  }
}
</script>

<style lang='css' scoped>
@import '../../../index.css';
</style>
